using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.Busi.Entity
{
	[Table("Drivers", "ID", "Busi.ConnectionString")]
	public class Drivers : Info
	{
		#region SQL column name consts 
		public const string SQLCOL_ID = "ID";
		public const string SQLCOL_NAME = "Name";
		public const string SQLCOL_SEX = "Sex";
		public const string SQLCOL_ISSPECIAL = "IsSpecial";
		public const string SQLCOL_ISVALID = "IsValid";
		public const string SQLCOL_GROUPID = "GroupID";
		public const string SQLCOL_GROUPNAME = "GroupName";
		public const string SQLCOL_BACKNVARCHAR = "BackNvarchar";
		public const string SQLCOL_BACKINT = "BackInt";
		#endregion


		#region Contructors
		/// <summary>
		/// Construct empty entity
		/// </summary>
		public Drivers () {}

		/// <summary>
		/// Construct entity by primary key, other fields will be assigned by 
		/// "Load" method.
		/// </summary>
		public Drivers (long ID)
		{
			this.ID = ID;
		}
		#endregion

		public override void Init (DataRow row)
		{
			ID = (long)ObjectType.LongTypeHelper.Read(row[SQLCOL_ID]);
			Name = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_NAME]);
			Sex = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_SEX]);
			IsSpecial = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_ISSPECIAL]);
			IsValid = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_ISVALID]);
			GroupID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_GROUPID]);
			GroupName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_GROUPNAME]);
			BackNvarchar = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_BACKNVARCHAR]);
			BackInt = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_BACKINT]);
		}

		#region Properties 
		#region Property <long> ID
		[Property("ID", 8, SqlDbType.BigInt, true, true)]
		public long ID 
		{
			get { return _ID; }
			set { _ID = value; }
		}
		private long _ID = long.MinValue;
		#endregion

		#region Property <string> Name
		[Property("Name", 40, SqlDbType.NVarChar, false, false)]
		public string Name 
		{
			get { return _Name; }
			set { _Name = value; }
		}
		private string _Name = null;
		#endregion

		#region Property <string> Sex
		[Property("Sex", 2, SqlDbType.Char, false, false)]
		public string Sex 
		{
			get { return _Sex; }
			set { _Sex = value; }
		}
		private string _Sex = null;
		#endregion

		#region Property <string> IsSpecial
		[Property("IsSpecial", 2, SqlDbType.Char, false, false)]
		public string IsSpecial 
		{
			get { return _IsSpecial; }
			set { _IsSpecial = value; }
		}
		private string _IsSpecial = null;
		#endregion

		#region Property <string> IsValid
		[Property("IsValid", 4, SqlDbType.Char, false, false)]
		public string IsValid 
		{
			get { return _IsValid; }
			set { _IsValid = value; }
		}
		private string _IsValid = null;
		#endregion

		#region Property <Guid> GroupID
		[Property("GroupID", 16, SqlDbType.UniqueIdentifier, false, false)]
		public Guid GroupID 
		{
			get { return _GroupID; }
			set { _GroupID = value; }
		}
		private Guid _GroupID = Guid.Empty;
		#endregion

		#region Property <string> GroupName
		[Property("GroupName", 100, SqlDbType.NVarChar, false, false)]
		public string GroupName 
		{
			get { return _GroupName; }
			set { _GroupName = value; }
		}
		private string _GroupName = null;
		#endregion

		#region Property <string> BackNvarchar
		[Property("BackNvarchar", 100, SqlDbType.NVarChar, false, false)]
		public string BackNvarchar 
		{
			get { return _BackNvarchar; }
			set { _BackNvarchar = value; }
		}
		private string _BackNvarchar = null;
		#endregion

		#region Property <int> BackInt
		[Property("BackInt", 4, SqlDbType.Int, false, false)]
		public int BackInt 
		{
			get { return _BackInt; }
			set { _BackInt = value; }
		}
		private int _BackInt = int.MinValue;
		#endregion
		#endregion


		public bool LoadByIdentity(long ID)
		{
			return DataAccess.SelectByIdentity(this, Convert.ToInt64(ID));
		}


		public bool DeleteByIdentity()
		{
			return DataAccess.DeleteByIdentity(this);
		}
	}
}
